package com.smh.jedis.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @author shiminghui
 * @date 2025/3/26 19:44
 * @description: TODO
 */
public class JedisConnectFactory {
    private final static JedisPool pool;

    static {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxTotal(10); // 最大连接数
        jedisPoolConfig.setMaxIdle(10); // 最大空闲连接数
        jedisPoolConfig.setMinIdle(0); // 最小空闲连接数
        jedisPoolConfig.setMaxWaitMillis(1000); // 最大等待时间

        pool = new JedisPool(jedisPoolConfig, "39.105.11.64", 6379, 1000, "123456");
    }

    public static Jedis getJedis() {
        return pool.getResource();
    }
}
